# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-zimscraperlib
pkgver=3.1.1
pkgrel=0
pkgdesc="Collection of python code to re-use across python-based scrapers"
url="https://github.com/openzim/python-scraperlib"
arch="noarch"
license="GPL-3.0-or-later"
depends="
	ffmpeg
	gifsicle
	py3-pillow
	py3-six
	wget
	"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="
	py3-babel
	py3-beautifulsoup4
	py3-colorthief
	py3-iso639
	py3-libzim
	py3-lxml
	py3-magic
	py3-optimize-images
	py3-piexif
	py3-pytest
	py3-pytest-cov
	py3-pytest-httpbin
	py3-resizeimage
	py3-requests
	py3-wsgiprox
	yt-dlp-core
	"
subpackages="$pkgname-pyc"
source="py3-zimscraperlib-$pkgver.tar.gz::https://github.com/openzim/python-scraperlib/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/python-scraperlib-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	# some tests may fail, so disable them
	# https://github.com/openzim/python-scraperlib/issues/114
	.testenv/bin/python3 -m pytest \
		-k "not test_get_media_info[mp4-video.mp4-expected1]"` \
		   `" and not test_reencode_media[video.mkv-video.mp4-ffmpeg_args0-expected0]"` \
		   `" and not test_selocale_unsupported"` \
		   `" and not test_installed_script" \
		--runslow --runinstalled \
		--cov=zimscraperlib \
		--cov-report=term --cov-report term-missing
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
9cd5af499770cb73d4fcc99f3ee5484c95dd3355e7b56275075aa5aebd5cfd72d39750edb4c13a9647447bb11a2c13fe35f4ce6ad95fab0c022b398382c21efa  py3-zimscraperlib-3.1.1.tar.gz
"
